package com.base.logistics.sf.request;

import com.base.logistics.sf.bean.RequestParams;
import com.base.logistics.sf.bean.routes.SearchRoutesRequest;
import com.base.logistics.sf.bean.routes.SearchRoutesResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * <pre>
 * 顺丰路由api接口实现
 * </pre>
 * @since 2021-02-17
 */
@Component
public class SfRoutesApiRequest{

    private SfRequestConfig sfApiRequestConfig;

    @Autowired
    public SfRoutesApiRequest(SfRequestConfig sfApiRequestConfig) {
        this.sfApiRequestConfig = sfApiRequestConfig;
    }

    public SearchRoutesResponse searchRoutes(SearchRoutesRequest request) throws Exception {
        RequestParams r = new RequestParams(request.getServiceCode(),request.toJson());
        return SearchRoutesResponse.fromJson(this.sfApiRequestConfig.post(r));
    }
}
